package org.goj.practice.utils;

import com.thoughtworks.xstream.XStream;

/**
 * @author CK
 * @date 2021/3/31 18:23
 */
public class XStreamUtil {

    public static Object toBean(Class<?> clazz, String xml) {
        Object xmlObject;
        XStream xstream = new XStream();
        xstream.processAnnotations(clazz);
        xstream.autodetectAnnotations(true);
        xmlObject= xstream.fromXML(xml);
        return xmlObject;
    }

    public static String toXml(Object o){
        XStream xstream = new XStream();
        return xstream.toXML(o);
    }

}
